import axios from 'axios'
import jsonp from 'common/jsonp'
import { options } from './config'
export function GetSinger() {

  const url = '/api/getSingerlist'
  const data = {
    '-': 'getUCGI47500360327073987',
    g_tk: 5381,
    loginUin: 1600086411,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
    data: {'comm':{'ct':24,'cv':0},'singerList':{'module':'Music.SingerListServer','method':'get_singer_list','param':{'area':-100,'sex':-100,'genre':-100,'index':-100,'sin':0,'cur_page':1}}}
  }

  return axios( url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function GetSingr1() {
  const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'
  const data = {
    g_tk: 1928093487,
    inCharset: 'utf-8',
    outCharset: 'utf-8',
    notice: 0,
    format: 'jsonp',
    channel: 'singer',
    page: 'list',
    key: 'all_all_all',
    pagesize: 100,
    pagenum: 1,
    hostUin: 0,
    needNewCode: 0,
    platform: 'yqq'
  }
  return jsonp(url,data,options)
}

export function getSingerDisc(singer){
  const url = '/api/getSingerDisc'
  const data = {
    '-': 'getUCGI6054148060059017',
    g_tk: 5381,
    loginUin: 1600086411,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
    data: {"comm":{"ct":24,"cv":0},"singer":{"method":"get_singer_detail_info","param":{"sort":5,"singermid":`${singer.id}`,"sin":0,"num":100},"module":"music.web_singer_info_svr"}}
  }
  return axios.get( url, { 
    params: data
  }).then((res) => {
    return Promise.resolve(res)
  })
}

export function getSongVkey(songmid) {
  const url = 'https://c.y.qq.com/base/fcgi-bin/fcg_music_express_mobile3.fcg'
  const data = {
    g_tk: 5381,
    hostUin: 0,
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq',
    needNewCode: 0,
    cid: 205361747,
    uin: 0,
    songmid: songmid,
    filename: `C400${songmid}.m4a`,
    guid: 7175649092,
    format: 'jsonp'
  }
  return jsonp(url, data)
}
